package edu.hwadee.BEIS;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import edu.hwadee.BEIS.aop.LoginInterceptor;


@Configuration
public class SpringMVCConfig extends WebMvcConfigurerAdapter {
	
	/**
	 * 添加拦截器
	 */
//	@Override
//	public void addInterceptors(InterceptorRegistry registry) {
//	    // addPathPatterns 用于添加拦截规则
//	    // excludePathPatterns 用户排除拦截
//	    registry.addInterceptor(new LoginInterceptor()).addPathPatterns("/**").excludePathPatterns("/html/login.html*","/html/register*.html*","/management/login","/management/register/**");
//	    super.addInterceptors(registry);
//	}
	
	/**
	 * 设置默认首页
	 */
	@Override
	public void addViewControllers(ViewControllerRegistry registry) {
		registry.addViewController("/").setViewName("forward:/html/login.html");
		registry.setOrder(Ordered.HIGHEST_PRECEDENCE);
		super.addViewControllers(registry);
	}
	
}
